﻿package com.lsmo.android.util;

import java.util.Hashtable;
import java.util.LinkedList;

/**
 * 缓存管理
 * @author SYX
 * @项目名称：carfans     
 * @类名称：FormatUtil 
 * @修改时间：2012-3-26 
 * @修改备注：
 */
public class RequestCache {
	private static int CACHE_LIMIT = 10;
	private Hashtable<String, String> cache;
	private LinkedList history;
	
	public RequestCache(){
		history = new LinkedList();
		cache = new Hashtable();
	}
	
	public String get(String paramString){
		return (String)cache.get(paramString);
	}
	
	public void put(String paramString1, String paramString2){
	    history.add(paramString1);
		// too much in the cache, we need to clear something
		if(history.size() > CACHE_LIMIT){
			String old_url = (String) history.poll();
			cache.remove(old_url);
		}
		cache.put(paramString1, paramString2);
	}
}
